<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*
        HTTP/1.1 200 OK
        http://localhost:3008/4.html
        1. 向服务器请求4.html，浏览器（下载）执行4.html
        2. 4.html 中的 xhr 向服务器请求 /users
        3. 浏览起下载 /users 资源内容
      */
      const xhr = new XMLHttpRequest();
      xhr.open("GET", "http://localhost:3008/users");
      xhr.timeout = 3000;
      xhr.onload = function () {
        console.log(xhr.status);
        console.log(xhr.statusText);
      };
      xhr.ontimeout = function () {
        console.log("超时了");
      };

      xhr.send();
    </script>
  </body>
</html>
